<?php /* @var $this Controller */ ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta name="language" content="en" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/> 
	<!-- blueprint CSS framework -->
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/screen.css" media="screen, projection" />
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/print.css" media="print" />
	<!--[if lt IE 8]>
	<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/ie.css" media="screen, projection" />
	<![endif]-->

    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/vote-m.css" media="screen and (max-width:568px)"/>
    <link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl; ?>/css/vote-w.css" media="screen and (min-width:600px)"/> 

     <script type="text/javascript" src="<?php echo Yii::app()->request->baseUrl; ?>/js/jquery-1.7.2.min.js"></script> 
	<title><?php echo CHtml::encode($this->pageTitle); ?></title></head>

<body>

	<div class="container" id="page">
         <a href="/"  id="headurl">
    		<div id="header"> 
    		</div>
         </a>
		<!-- header --> 
    <div id="headers">

           <div id="logo"><img src="images/m/back.png" border="0" onclick="javascript:window.location.href='<?php echo Yii::app()->createUrl('vote/index');?>'"><span class="logotitle">投票</span></div>


    </div><!-- header --> 
		<div id="mainmenu">&nbsp;<img src="images/w/close.png" border="0" onclick="javascript:window.location.href='<?php echo Yii::app()->createUrl('vote/index');?>'">
          <div style="text-align:center"><a href="<?php echo Yii::app()->createUrl('vote/notice');?>" style="font-size:1.6em" target="_blank">曲江新区2013第二届导游讲解员大赛网络投票说明</a></div>
    </div>
		<!-- mainmenu -->
        <div id="show_view_pic">

		<div class="span-1">&nbsp;</div>
		<div class="span-11">
			<div id="content">

				<div class="candidate">
					<img src="<?php echo Yii::app()->baseUrl.$info->thumbnail ?>" class="thumbnail" alt="" id="showbigpic">
					<div class="vinfo" id="pollvalue">
						<?php echo $info->poll ?>票</div>
					<div class="cinfo">
						<span class="info">
							<span class="numspan">
								<?php echo $info->numbers ?>号</span>
							<br>
							<span>
								姓名：
								<?php echo $info->title ?></span>
							<br>
							<span>
								景区：
								<?php echo $info->befrom ?></span>
						</span>

						<span class="vote">
							<img src="images/w/poll.png" border="0"  onclick="javascript:addpull();" id='pullimg'/>
							<br/>
							<span class="vote_pull" >投票</span>
						</span>
					</div>

				</div>
			</div>
			<!-- content -->
		</div>
		<div class="span-4">
			<div id="sidebar">
				<ul class="right_thumb" id="right_thumb">
					<li id="img_li_0">
						<a href="javascript:void(0);" onclick="showpic(0);">
							<img src="<?php echo Yii::app()->baseUrl.$info->thumbnail ?>" id="img_0" class="showview"/></a>
					</li>
					<?php 
				 	 $i=0;
				 	 foreach($pics as $v){ 
				 	 	$i++;
				 	 ?>
					<li id="img_li_<?php echo $i ?>">
						<a href="javascript:void(0);" onclick="showpic(<?php echo $i ?>);">
							<img src="<?php echo Yii::app()->baseUrl.$v['url'] ?>" id="img_<?php echo $i ?>"/></a>
					</li>
					<?php }?></ul>
			</div>
			<!-- sidebar -->
		</div>
    </div>
		<div class="span-9 last" >
			<div id="sidebar" class="leftline">
				<div class="advice_title">
					<?php echo $info->description ?></div>
				<div class="advice_list" id="advice_list">
					<?php foreach($comments as $v){ ?>
                    <div class="advice_list_chicle">
    					<div class="hp">
    						<img src="<?php echo $v['avatar'] ?>"/>
    					</div>
    					<div class="tips">
    						<span class='name'><?php echo $v['email'] ?></span>
    						<span><?php echo $v['content'] ?></span>
    						<br>
    						<span class='time'><?php $date = new DateTime($v['createtime']);echo $date->format('Y-m-d') ?></span>
    					</div>
    					<div class="clear"></div>
                </div>
				 <?php }?> 
				</div>  
          <div id="pager">  
              <?php  
            
              $this->widget('CLinkPager',array(  
                  'header'=>'',  
                  'firstPageLabel' => '首页',  
                  'lastPageLabel' => '末页',  
                  'prevPageLabel' => '上一页',  
                  'nextPageLabel' => '下一页',  
                  'pages' => $pages,  
                  'maxButtonCount'=>5  
                  )  
              );  
              ?>  
              </div>   
				<div id="inputs">
					<input type="text" name="email" id="comment_email" value="邮箱" class="inputemail color888"><br>
					<input type="text" name="content" id="comment_content" value="发表评论" class="color888"><br>
					<button id="inbutton" onclick="javascript:updateComment();"></button>
				</div>
			</div>
			<!-- sidebar -->
		</div>

		<div class="clear"></div>

		<div id="footer">
		主办单位： 曲江新区管理委员会<Br>
		协办单位： 西安曲江文化旅游股份有限公司<br> 
    技术支持： 西安有道软件技术有限公司<br><br>
		<img src="images/logo.png" border=0 id="footimg">		
		<br><br>
        <script type="text/javascript">
          function getVoide(objName){
                var arrStr = document.cookie.split(";"); 
                for(var i = 0;i < arrStr.length;i ++){ 
                    var temp = arrStr[i].split("="); 
                    if(temp[0] == objName) return unescape(temp[1]);  
               } 
               return ""; 
            }
            var _bdhmProtocol = (("https:" == document.location.protocol) ? " https://" : " http://");
            document.write(unescape("%3Cscript src='" + _bdhmProtocol + "hm.baidu.com/h.js%3F202fabbe66a9248b12d2feb9e9e9c61b' type='text/javascript'%3E%3C/script%3E")); 
            if(getVoide("vote2013")==""){
                var exp = new Date();
                exp.setTime(exp.getTime() + 30*24*60*60*1000);  
                document.cookie ="vote2013="+ escape ("vote2013_"+new Date().getTime()) + ";expires=" + exp.toGMTString();
            } 
        </script> 
		</div>
		<!-- footer -->

	</div>
	<!-- page -->
 <!-- 弹出层 -->
    <div id='pop-div' style="width: 300px" class="pop-box" > 
        <h4>请输入验证码<span class="closespan">[×]</span></h4> 
        <div class="pop-box-body" > 
        <p id="viewcapthca"> 
            <?php $this->widget('CCaptcha',array('id'=>'captcha_id','buttonLabel'=>'点击刷新验证码')); ?>
            <br>
            <input type="text" name="capthca" id="capthcavalue">  
        <input value="提交" id="btn1" onclick="subbtn();" type="button" /> 
        </p> 
        </div>  
    </div>
    <!-- 遮罩层 -->
    <div id="fade" class="black_overlay"></div> 
    <style type="text/css">
    .pop-box { 
        z-index: 9999; /*这个数值要足够大，才能够显示在最上层*/ 
        margin-bottom: 3px; 
        display: none; 
        position: absolute; 
        background: #FFF; 
        border:solid 1px #6e8bde; 
    } 

    .pop-box h4 { 
        color: #FFF; 
        cursor:default; 
        height: 18px; 
        font-size: 14px; 
        font-weight:bold; 
        text-align: left; 
        padding-left: 8px; 
        padding-top: 4px; 
        padding-bottom: 2px; 
        background-color: #6e8bde; 
        margin-bottom: 0.8em;
    } 
    #btn1{
        margin-top: 10px;
        width: 80px;
        height: 29px;
        background-color: #ec6a00;
        color: #ffffff;
        text-align: center;
        font-size: 20px;
        border: 0;
    }

    .pop-box-body { 
        clear: both; 
        margin: 4px; 
        padding: 2px; 
    }
    .pop-box-body p{
        margin: 0px;
        text-align: center;
    }
    .black_overlay{
        display: none;
        position: absolute;
        top: 0%;
        left: 0%;
        width: 100%;
        height: 100%;
        background-color: black;
        z-index:1001;
        -moz-opacity: 0.6;
        opacity:.60;
        filter: alpha(opacity=60);
      }
     .closespan{
        float: right;
        padding-right: 10px;
        font-size: 1.3em;
        margin-top: -5px;
    }
    </style>
    <script type="text/javascript">
    $(document).ready(function(){
          $("#comment_email").focus(function(){
            if($("#comment_email").val()=="邮箱"){
              $("#comment_email").val('');
                        $("#comment_email").removeClass('color888');
            }
        });
        $("#comment_content").focus(function(){
          if ($("#comment_content").val()=="发表评论") {
              $("#comment_content").val('');
                        $("#comment_content").removeClass('color888');
            }
        });
        $("#comment_email").blur(function(){
            if($("#comment_email").val()==""){
              $("#comment_email").val('邮箱');
                        $("#comment_email").addClass('color888');
            }
        });
        $("#comment_content").blur(function(){
            if($("#comment_content").val()==""){
              $("#comment_content").val('发表评论');
                        $("#comment_content").addClass('color888');
            }
        });
    });
          function showpic(obj){ 
            var a_arr = $("#right_thumb").find('img');
          for (var i = 0; i < a_arr.length; i++) { 
             $(a_arr[i]).removeClass('showview');
          }; 
         $("#img_"+obj).addClass('showview'); 
         $("#showbigpic").attr('src',$("#img_"+obj).attr('src'));
          }

          function updateComment(){
            var comment_email=$('#comment_email').val();
            var comment_content=$('#comment_content').val();
            var candidateid="<?php echo $info->id ?>";
            if(comment_email==null||comment_content==null){
              alert("请填写邮箱/评论"); 
              return false;
            }
          if(!comment_email.match(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/)){
             alert("邮箱格式不正确！请重新输入");
              $('#comment_email').focus();
              return false;
           }
        $.post("<?php echo Yii::app()->createUrl('vote/postComment');?>",{'email':comment_email,'candidateid':candidateid,'content':comment_content},function(result){
            if(result.code==0){
              $('#comment_email').val("邮箱");
                      $("#comment_email").addClass('color888');
              $('#comment_content').val("发表评论");
                     $("#comment_content").addClass('color888');
              
              var html=' <div class="advice_list_chicle"><div class="hp">'+
              '<img src="images/w/defule.jpg" />'+
            '</div>'+
            '<div class="tips">'+
            ' <span class="name">'+comment_email+'</span>'+
              '<span>'+comment_content+'</span>'+
              '<br>'+
              '<span class="time">'+getnewDate()+'</span>'+
            '</div>'+
            '<div class="clear"></div></div>';
                $(html).prependTo('#advice_list');
               alert(result.message); 
            }else{
              alert(result.message); 
            }
            },'json');
          }
          function addpull(){
             $('#pullimg').attr('src','images/w/poll-down.png');
             //$('#captcha_id_button').click();
             popupDiv($("#pop-div"));  
          }

         //弹出层
          function popupDiv(obj){
              //显示遮罩层 
            document.getElementById("fade").style.display='block' ;
            var bgdiv = document.getElementById("fade");
            bgdiv.style.width = document.body.scrollWidth; 
            $("#fade").height($(document).height()); 

             $(obj).show();
             center(obj);
             $(window).scroll(function(){
                center(obj);
             });
             $(window).resize(function(){
                 center(obj);
             }); 
            }

            function center(obj){
                 var windowWidth = document.documentElement.clientWidth;   
                 var windowHeight = document.documentElement.clientHeight;   
                 var popupHeight = $(obj).height();   
                 var popupWidth = $(obj).width();    
                 $(obj).css({   
                  "position": "absolute",   
                  "top": (windowHeight-popupHeight)/2+$(document).scrollTop(),   
                  "left": (windowWidth-popupWidth)/2   
                 });  
            }


           function subbtn() { 
                $("#fade").hide(); 
                $("#pop-div" ).hide(); 
                if($("#capthcavalue").val()==''){
                     alert("请输入验证码!");
                }else{
                  var  capthcavalue= $("#capthcavalue").val(); 
                 var id="<?php echo $info->id ?>";
                      $.post("<?php echo Yii::app()->createUrl('vote/addpull');?>",{'id':id,'cookies':getVoide("vote2013"),'capthcavalue':capthcavalue},function(result){
                        if(result.code==0){
                            alert(result.message); 
                            $('#pollvalue').html(result.poll+"票");
                        }else{
                            if(result.code!=-3){
                                alert(result.message); 
                                 $('#pullimg').attr('src','images/w/poll.png');
                             } 
                        }
                         $("#capthcavalue").val("");
                         $('#captcha_id_button').click();
                     },'json');
                }
               
            }

            $(".closespan").live('click',function(){
              $("#fade").hide(); 
              $("#pop-div" ).hide(); 
              $('#pullimg').attr('src','images/w/poll.png');
           });

          function getnewDate(){
          var data = new Date();  
          var year = data.getFullYear();  //获取年
          var month = data.getMonth() + 1;    //获取月
          var day = data.getDate(); //获取日
          return year+'-'+month+"-"+day;
          }
    </script>
</body>
</html>
